<?php

namespace catchAdmin\pc\model;

use catcher\exceptions\AlertErrorException;
use thans\jwt\facade\JWTAuth;
use think\facade\Db;

class UserCompanyExt extends \catchAdmin\model\UserCompanyExt
{

    public function saveData($param)
    {
        $user_company_msg = (new \catchAdmin\model\UserCompany())
            ->where('wechat_user_id', $this->getPcLoginWechatUserId())
            ->find();

        if (empty($user_company_msg)) {
            throw new AlertErrorException();
        }

        $param['user_company_id'] = $user_company_msg['id'];

        $msg = $this
            ->where('user_company_id', $user_company_msg['user_company_id'])
            ->find();
        $param['id'] = $msg['id'] ?? 0;

        $this->saveDataCC($param);

        return 1;
    }

}
